# coding: utf-8
"""Kitchen URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/1.11/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  url(r'^$', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  url(r'^$', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.conf.urls import url, include
    2. Add a URL to urlpatterns:  url(r'^blog/', include('blog.urls'))
"""
from django.conf.urls import url, include
# from django.contrib import admin
from django.views.static import serve
from django.conf import settings
import xadmin

from users.views import (
    IndexView, LoginView, RegisterView, LogoutView,
    ActiveUserView, ForgetView, ResetView, ModifypwdView
)
from users.views import page_not_found, server_error
from users.views import ajax_val
from cookbook.views import SearchView

urlpatterns = [
    url(r'^$', IndexView.as_view(), name='index'),
    url(r'^login/$', LoginView.as_view(), name='login'),
    url(r'^active/(?P<active_code>.*)/$', ActiveUserView.as_view(), name='user_active'),
    url(r'^forget/$', ForgetView.as_view(), name='forget_pwd'),
    url(r'^reset/(?P<active_code>.*)/$', ResetView.as_view(), name='reset_pwd'),
    url(r'^modifypwd/$', ModifypwdView.as_view(), name='modify_pwd'),
    url(r'^logout/$', LogoutView.as_view(), name='logout'),
    url(r'^register/$', RegisterView.as_view(), name='register'),
    url(r'^captcha/', include('captcha.urls')),
    url(r'^ajax_val/', ajax_val, name='ajax_val'),
    url(r'^search/$', SearchView.as_view(), name='search'),

    url(r'^users/', include('users.urls', namespace='users')),

    url(r'^cookbook/', include('cookbook.urls', namespace='cookbook')),

    url(r'^community/', include('community.urls', namespace='community')),

    url(r'^ckeditor/', include('ckeditor_uploader.urls')),

    url(r'^media/(?P<path>.*)/$', serve, {'document_root': settings.MEDIA_ROOT}),

    # url(r'^admin/', admin.site.urls),
    url(r'^xadmin/', xadmin.site.urls),
]

# 全局404
handler404 = page_not_found

# 全局500
handler500 = server_error
